/* components */
import ChatAIView from '@src/component/business/BizChatPanel/chat/view'
/* enum */
import { ComponentNameEnum } from '@src/component/business/BizChatPanel/chat/model/enum'
/* scss */
import '@src/component/business/BizChatPanel/chat/index.scss'
/* vue */
import { defineComponent, ref, PropType } from 'vue'
/* types */
import { SettingGPTServiceItem } from '@gpt/types'

type ChatAIViewComponent = InstanceType<typeof ChatAIView>

export type ChatAIIndexProps = {
  
}

export interface ChatAIIndexSetupState {
  
}

export enum ChatAIIndexEventEnum {
  Input = 'input',
  AppTag = 'appTag'
}

export default defineComponent({
  name: ComponentNameEnum.ChatAIIndex,
  components: {
    ChatAIView
  },
  props: {
    isShare: {
      type: Boolean,
      default: false
    },
    robotId: {
      type: String,
      default: ''
    },
    tenantId: {
      type: String,
      default: ''
    },
    userId: {
      type: String,
      default: ''
    },
    stream: {
      type: Boolean,
      default: false
    },
    currentApp: {
      type: Object as PropType<SettingGPTServiceItem>,
      default: () => ({})
    },
    disabled: {
      type: Boolean,
      default: false
    },
    chatSystemMessage: {
      type: String,
      default: ''
    },
    onAppTag: {
      type: Function
    }
  },
  computed: {
    //
  },
  created() {
    // 
  },
  methods: {
    init() {
      (this.$refs.ChatAIView as ChatAIViewComponent)?.initializeFetch()
    },
    initWithChangeApp() {
      (this.$refs.ChatAIView as ChatAIViewComponent)?.initializeFetchWithChangeApp()
    },
    onAppTagHandler() {
      this.$emit(ChatAIIndexEventEnum.AppTag)
    }
  },
  render() {
    return (
      <div class={ComponentNameEnum.ChatAIIndex}>
        
        <ChatAIView 
          ref="ChatAIView" 
          isDisabled={this.disabled}
          isShare={this.isShare}
          tenantId={this.tenantId} 
          robotId={this.robotId}
          userId={this.userId}
          stream={this.stream}
          currentApp={this.currentApp}
          chatSystemMessage={this.chatSystemMessage}
          onAppTag={this.onAppTagHandler}
        />
        
      </div>
    ) as any
  }
})
